<template>
  <div :class="className">
    <!-- style -->
    <div v-html="css"></div>

    <!--门店静态-->
    <div>
      <div id="store" v-if="datas.get_number">
        <div class="nav nav-bgimage" v-if="datas.tab_list && datas.tab_list.length > 0">
          <div class="nav-li nav-selected" v-if="datas.tab_list.indexOf('1') > -1">
            <div class="nav-lis">
              商家
            </div>
          </div>
          <div class="nav-li" v-if="datas.tab_list.indexOf('2') > -1">
            <div class="nav-lis">
              折扣
            </div>
          </div>
          <div class="nav-li" v-if="datas.tab_list.indexOf('3') > -1">
            <div class="nav-lis">
              优惠券
            </div>
          </div>
          <div class="nav-li" v-if="datas.tab_list.indexOf('4') > -1">
            <div class="nav-lis">
              礼包
            </div>
          </div>
        </div>
        <div class="store-list" v-if="!datas.sort_style || datas.sort_style == 1">

          <div class="item-top">
            <div class="left">
              <div class="image">
                <img src="../../../resource/images/image.png" alt="" />
              </div>
              <div class="category">
                分类
              </div>
            </div>
            <div class="right">
              <div class="title">商城专营店(广场)</div>
              <div class="sale">
                <div class="grade">
                  <i class="iconfont icon-card_collect_b"></i>
                  <span>5分</span>
                </div>
                <div class="num" v-if="datas.discount_list.indexOf('1') > -1">已售25485单</div>
                <div class="num" v-if="datas.discount_list.indexOf('1') < 0"></div>
                <div class="distance">15.0km</div>
              </div>
              <div class="discounts">
                <div class="discounts-list" v-if="datas.discount_list.indexOf('4') > -1">
                  <div class="type">优惠</div>
                  <div class="con">300减100</div>
                  <div class="con">700减300</div>
                </div>
                <div class="discounts-list" v-if="datas.discount_list.indexOf('3') > -1">
                  <div class="type">抵扣</div>
                  <div class="con">爱心值20%</div>
                  <div class="con">积分20%</div>
                </div>
                <div class="discounts-list" v-if="datas.discount_list.indexOf('2') > -1">
                  <div class="type">赠送</div>
                  <div class="con">爱心值20%</div>
                </div>
              </div>
              <div class="label" v-if="datas.show_tag_view">
                <div class="label-list">
                  <div class="label-title">支持快递</div>
                  <div class="label-title">自提</div>
                  <div class="label-title">核销</div>
                  <div class="label-title">支持人脸</div>
                </div>
              </div>
            </div>
          </div>
          <div class="goods" v-if="datas.show_goods && datas.content_list">
            <div class="goods-list">
              <div class="goods-one" v-for="item in 4">
                <div class="goods-image">
                  <img src="../../../resource/images/image.png" alt="" />
                </div>
                <div class="goods-title">商品标题</div>
                <template v-for="content in show_content_list">
                  <div class="oneChild_sales" v-if="datas.content_list.includes(content.code)" v-show="!datas.content_list.includes(content.notIncludes)">{{content.title}}</div>
                </template>
                <div class="price">￥1250.00</div>
              </div>
            </div>
          </div>

        </div>

        <div class="list-02" v-if="datas.sort_style == 2">
          <div class="list-top">
            <div class="store-img">
              <img class="store-logo" src="../../../resource/images/image.png" />
            </div>
            <div class="store-info">
              <div class="store-name text-ellipsis">商城专营店(广场)</div>
              <div class="store-score">
                <div class="left">
                  <i class="iconfont icon-card_collect_b"></i><i class="iconfont icon-card_collect_b"></i>
                  <i class="iconfont icon-card_collect_b"></i><i class="iconfont icon-card_collect_b"></i>
                  <i class="iconfont icon-card_collect_b"></i>
                  <div class="score">5分</div>
                </div>
                <div class="right" style="color: #ee7d07;" v-if="datas.discount_list.indexOf('1') > -1">已售25485单</div>
              </div>
              <div class="store-address">
                <div class="left">
                  <div class="category text-ellipsis">分类</div>
                  <div class="line"></div>
                  <div class="address text-ellipsis">
                    <template>广州市</template>
                    <template>白云区</template>
                  </div>
                </div>

                <div class="right">
                  15.0km<i class="iconfont icon-all_daohang"></i>
                </div>
              </div>
              <div class="" v-if="datas.show_tag_view">
                <div class="dispatch-box">
                  <div class="dispatch-item">支持快递</div>
                  <div class="dispatch-item">自提</div>
                  <div class="dispatch-item">核销</div>
                  <div class="dispatch-item">支持人脸</div>
                </div>
              </div>
            </div>
          </div>
          <div class="discount-box">
            <p class="discount-item" v-if="datas.discount_list.indexOf('4') > -1">
              <span class="red">优惠</span>
              <span style="margin-left: 7px;">300减100</span>
              <span style="margin-left: 7px;">700减300</span>
            </p>
            <p class="discount-item" v-if="datas.discount_list.indexOf('2') > -1">
              <span class="red">赠送</span>
              <span style="margin-left: 7px;">爱心值20%</span>
              <span style="margin-left: 7px;">积分20%</span>
            </p>
            <p class="discount-item" v-if="datas.discount_list.indexOf('3') > -1">
              <span class="red">抵扣</span>
              <span style="margin-left: 7px;">爱心值20%</span>
              <span style="margin-left: 7px;" :class="{ store_deduction_style: true }">积分20%</span>
            </p>
            <!--<p class="discount-item" v-if="datas.discount_list.indexOf('5') > -1">-->
              <!--<span class="red">满减</span>-->
              <!--<span style="margin-left: 7px;">满100减5</span>-->
              <!--<span style="margin-left: 7px;">满200减25</span>-->
            <!--</p>-->
            <!--<p class="discount-item" v-if="datas.discount_list.indexOf('6') > -1">-->
              <!--<span class="red">包邮</span>-->
              <!--<span style="margin-left: 7px;">满100包邮</span>-->
            <!--</p>-->
          </div>

          <div class="goods-box" v-if="datas.show_goods && datas.content_list">
            <div class="good-item" v-for="(good, i) in 4" :key="i">
              <div class="good-img">
                <img src="../../../resource/images/image.png" alt="" />
              </div>
              <p class="good-title">商品标题</p>
              <template v-for="content in show_content_list">
                <div class="oneChild_sales" v-if="datas.content_list.includes(content.code)" v-show="!datas.content_list.includes(content.notIncludes)">{{content.title}}</div>
              </template>
              <p class="good-price">￥1250.00</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
	import emptyImage from "@/resource/images/banner.png";
// 自定义样式
const css = function() {
	if (this.datas.preview_color) {
		// 确保数据已传入
		const {
			preview_color,
			font_size,
			font_color,
			border_radius,
			class_font_size,
			class_font_color,
			class_bg_color,
			class_border_radius,
			location_font_size,
			location_font_color,
			discount_font_size,
			discount_title_color,
			discount_font_color,
			tag_font_size,
			tag_font_color,
			tag_bg_color,
			tag_border_color,
			tag_border_radius,
			tab_bg_color,
			tab_color,
			tab_active_color,
		} = this.datas;

		return `
        .component-${this.id} .store-list,.component-${this.id} .list-02{
            background-color: ${preview_color};
        }

        .component-${this.id} .store-list .right .title, .component-${this.id} .list-02 .store-info .store-name{
            font-size: ${font_size}px;
            color: ${font_color};
        }

        .component-${this.id} .store-list .left .image img, .component-${this.id} .list-02 .list-top .store-img{
            border-radius: ${border_radius}px;
        }

        .component-${this.id} .store-list .right .distance, .component-${this.id} .list-02 .store-info .store-address .right{
            font-size: ${location_font_size}px;
            color: ${location_font_color};
        }

        .component-${this.id} .store-list .category, .component-${this.id} .list-02 .store-info .store-address .left .category{
            background-color: ${class_bg_color};
            border-radius: ${class_border_radius}px;
            font-size: ${class_font_size}px;
            color: ${class_font_color};
        }

        .component-${this.id} .store-list .discounts .discounts-list, .component-${this.id} .list-02 .discount-box .discount-item{
            font-size: ${discount_font_size}px;
        }

        .component-${this.id} .store-list .discounts .discounts-list .con, .component-${this.id} .list-02 .discount-box .discount-item{
            color: ${discount_font_color};
        }

        .component-${this.id} .store-list .discounts-list .type, .component-${this.id} .list-02 .discount-box .discount-item .red{
            color: ${discount_title_color};
        }

        .component-${this.id} .store-list .label-list .label-title, .component-${this.id} .list-02 .store-info .dispatch-box .dispatch-item{
            background-color: ${tag_bg_color};
            border-radius: ${tag_border_radius}px;
            border: solid  1px ${tag_border_color};
            font-size: ${tag_font_size}px;
            color: ${tag_font_color};
        }

        .component-${this.id}  .nav-bgimage{
            background-color: ${tab_bg_color};
            color: ${tab_color};
        }

        .component-${this.id}  .nav-bgimage .nav-selected{
            color: ${tab_active_color};
             border-bottom: 2px solid ${tab_active_color};
        }

    `;
	}
};

export default {
  data() {
    return {
	    emptyImage,
	    show_content_list: [
		    {title: '消费积分抵扣 8%',code:'8'},
		    {title: '爱心值激活 8%',code:'9'},
		    {title: '手续费 8%',code:'10'},
	    ]
    };
  },
  props: ["id", "datas", "styles"],
  computed: {
    css() {
      return "<style>" + css.call(this) + "</style>";
    },
    className() {
      const name = ["component-wrapper", `component-${this.id}`];
      return name;
    },
  },

  methods: {
    // rem转换
    px2rem(val = 0) {
      return val / 75 + "rem";
    },
  },

  mounted() {
    this.$emit("loaded");
  },
};
</script>

<style lang="less" scoped>
// 默认
* {
  list-style-type: none;
}
.component-wrapper {
  width: 375px;
}
#store {
  .nav {
    display: flex;
    align-items: center;
    height: 40px;
    white-space: nowrap;
    flex-wrap: nowrap;
    box-sizing: content-box;
    .nav-li {
      flex: 1;
      min-width: 20%;
      text-align: center;
      .nav-lis {
        display: inline-block;
        line-height: 40px;
      }
    }
  }
  .store-list {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    overflow: hidden;
    padding: 10px;
    .item-top {
      display: flex;
      width: 100%;
    }
    .left {
      width: 93.75px;
      text-align: center;
      .image {
        width: 70px;
        height: 70px;
        /*border-radius: 50%;*/
        margin: 0 10px;
        img {
          width: 100%;
          height: 100%;
          /*border-radius: 50%;*/
        }
      }
      .category {
        margin-top: 10px;
        display: inline-block;
        /*background: #adadad;*/
        /*color: #fff;*/
        /*border-radius: 5px;*/
        padding: 1px 5px;
      }
    }
    .right {
      width: 281.25px;
      .title {
        font-weight: 600;
        /*color: #000;*/
        /*font-size: 14px;*/
      }
      .sale {
        font-size: 12px;
        color: #666;
        display: flex;
        width: 100%;
        .grade {
          padding-right: 5px;
          i {
            color: #ffba00;
            font-size: 12px;
          }
        }
        .num {
          flex: 1;
        }
        .distance {
          text-align: right;
          width: 100px;
          padding-right: 10px;
        }
      }
      .discounts {
        .discounts-list {
          display: flex;
          align-items: center;
          /*font-size: 12px;*/
          justify-content: start;
          overflow: hidden;
          .type {
            /*font-size: 12px;*/
            /*color: #ff2c29;*/
            font-weight: 600;
            padding-right: 10px;
          }
          .con {
            padding-right: 10px;
            /*color: #000;*/
          }
        }
      }
      .label {
        font-size: 12px;
        .label-list {
          display: flex;
          align-items: center;
          .label-title {
            margin-right: 10px;
            padding: 0px 5px;
            /*background: #fff;*/
            /*color: #666;*/
            /*border: 1px solid #ff8400;*/
            /*border-radius: 6px;*/
          }
        }
      }
    }

    .goods {
      width: 100%;
      font-size: 12px;
      margin-top: 10px;
      box-sizing: border-box;
      .goods-list {
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
        width: 100%;

        .goods-one {
          margin-right: 10px;
          width: 90px;
          .goods-image {
            width: 90px;
            height: 90px;
            border-radius: 5px;
            img {
              width: 100%;
              height: 100%;
              border-radius: 5px;
            }
          }
          .goods-title {
            margin-top: 5px;
            width: 100%;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
          .oneChild_sales {
            font-size: 12px;
          }
          .price {
            color: #ff2c29;
            font-weight: 600;
          }
        }
      }
    }
  }

  .list-02 {
    margin: 10px;
    overflow: hidden;
    border-radius: 8px;
    padding: 10px;
    .list-top {
      width: 100%;
      display: flex;

      .store-img {
        width: 130px;
        height: 95px;
        background-color: #d5d5d5;
        /*border-radius: 5px;*/
        position: relative;
        overflow: hidden;
        .store-logo {
          width: 100%;
          height: 100%;
          object-fit: cover;
        }
        .img-mask {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          display: inline-block;
          background-color: rgba(59, 64, 67, 0.6);
        }
        .img-text {
          text-align: center;
          color: #fff;
          position: absolute;
          top: 50%;
          transform: translateY(-50%);
          left: 0;
          width: 100%;
        }
      }
    }
    .store-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      margin-left: 7px;
      // overflow: hidden;
      justify-content: space-between;
      .store-name {
        /*font-size: 16px;*/
        /*color: #303030;*/
        text-align: left;
      }
      .store-score,
      .store-address {
        display: flex;
        justify-content: space-between;
        font-size: 10px;
        .left {
          display: flex;
          align-items: center;
          .score {
            color: #969696;
            margin-left: 7px;
          }
        }
        /*.right {*/
          /*color: #ee7d07;*/
        /*}*/
        .iconfont {
          color: #ff2c29;
        }
      }
      .store-address {
        display: flex;
        overflow: hidden;
        .left {
          overflow: hidden;
          .category {
            max-width: 42px;
            /*color: #f08316;*/
          }
          .address {
            max-width: 87.5px;
            color: #464646;
          }
        }
        .right {
          display: flex;
          align-items: center;
          /*color: #969696;*/
          i {
            color: #ec544a;
            font-size: 20px;
          }
        }
      }
      .shadow-box {
        width: 100%;
        position: relative;
        // box-shadow: inset -15px 0px 10px -15px #000;
        &:before {
          content: "";
          position: absolute;
          top: -3px;
          right: -14px;
          width: 22px;
          height: 22px;
          background-size: 100% 100%;
          background-image: url(https://www.yunzmall.com/min_img/input-shadow.png);
          z-index: 10;
          // border-top-left-radius: 100%;
          // border-bottom-left-radius: 100%;
          // background: -webkit-linear-gradient(left, transparent, rgba(59, 64, 67, 0.6)); /* Safari 5.1 - 6.0 */
          // background: -o-linear-gradient(right, transparent, #333); /* Opera 11.1 - 12.0 */
          // background: -moz-linear-gradient(right, transparent, #333); /* Firefox 3.6 - 15 */
          // background: linear-gradient(to right, transparent, rgba(59, 64, 67, 0.5)); /* 标准的语法 */
        }
      }
      .dispatch-box {
        display: flex;
        width: 100%;
        overflow-x: scroll;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE 10+ */

        .dispatch-item {
          /*height: 15px;*/
          /*line-height: 15px;*/
          /*background-color: #f08316;*/
          /*border-radius: 2px;*/
          padding: 0 6px;
          margin-right: 6px;
          flex-shrink: 0;
          /*font-size: 10px;*/
          /*color: #fff;*/
        }
        // &::before {
        //   height: 100%;
        //   width: 10px;
        //   content: "";
        //   background: #000;
        // }
      }
      .dispatch-box::-webkit-scrollbar {
        display: none; /* Chrome Safari */
      }
    }
    .discount-box {
      display: flex;
      flex-wrap: wrap;
      .discount-item {
        margin: 8px 8px 8px 0;
        height: 14px;
        line-height: 14px;
        /*color: #282828;*/
        /*font-size: 10px;*/
        .red {
          border-radius: 2px;
          background-color: #ec544a;
          padding: 0 6px;
          /*color: #fff;*/
          position: relative;
          &:after {
            content: "";
            position: absolute;
            top: 0px;
            right: -5px;
            border-top: 8px solid transparent;
            border-left: 6px solid #ec544a;
            border-bottom: 8px solid transparent;
          }
        }
      }
    }
    .goods-box {
      margin: 7px 0 0;
      display: flex;
      overflow-x: scroll;
      scrollbar-width: none; /* Firefox */
      -ms-overflow-style: none; /* IE 10+ */
      .good-item {
        width: 84px;
        margin-right: 7.84px;
        font-size: 15px;
        text-align: left;
        display: flex;
        flex-direction: column;

        .good-img {
          width: 84px;
          height: 84px;
          border-radius: 5px;

          img {
            width: 100%;
            height: 100%;
            border-radius: 5px;
          }
        }

        .good-title {
          font-weight: bold;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          font-size: 12px;
          margin-bottom: 7px;
        }
        .oneChild_sales {
          font-size: 12px;
        }

        .good-price {
          font-weight: bold;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          font-size: 11px;
          color: #ff2c29;
          margin-bottom: 7px;
        }
      }

      /* 门店拼团 */
      .show_price_box {
        display: flex;
        flex-wrap: wrap;
      }

      .show_price {
        font-size: 11px;
        color: #ff2c29;
        border: solid #ff2c29 1px;
        padding: 1px 4px;
        margin-top: 5px;
      }

      .red_white {
        color: #fff;
        background: #ff2c29;
        margin-right: 5px;
      }

      .white_red {
        color: #ff2c29;
        background: #fff;
      }

      .store_deduction_style {
        background: #ff2c29;
        color: #fff;
        padding: 0 5px;
        font-size: 10px;
      }

      .store_cash_back_style {
        border: 1px solid #ff2c29;
        color: #ff2c29;
        padding: 0 5px;
        font-size: 10px;
      }

      /* 门店拼团 */
      &::-webkit-scrollbar {
        display: none; /* Chrome Safari */
      }
    }
  }
  .text-ellipsis {
    overflow: hidden; /*超出部分隐藏*/
    text-overflow: ellipsis; /* 超出部分显示省略号 */
    white-space: nowrap; /*规定段落中的文本不进行换行 */
  }
  .line {
    width: 1px;
    height: 50%;
    background: #bbbbbb;
    margin: 0 5px;
  }
  .scroll {
    overflow-x: scroll;
  }
}
</style>
